package com.zb.yaml;

import com.zb.utils.ZbManager;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 加密解密密钥
 * @Author WEN
 * @Date 2023/9/15 0015
 **/
@Component
public class EnDeSecret implements InitializingBean {
    private static EnDeSecret enDeSecret;
    // 获取系统内部公钥
    @Value("${secretKey.rsa.zb.publicKey}")
    private String zbRsaPublicKey;
    // 获取系统内部私钥
    @Value("${secretKey.rsa.zb.privateKey}")
    private String zbRsaPrivateKey;

    @Value("${secretKey.aes.zb}")
    private String zbAesKey;

    @Override
    public void afterPropertiesSet() throws Exception {
        enDeSecret = this;
        enDeSecret.zbRsaPublicKey = this.zbRsaPublicKey;
        enDeSecret.zbRsaPrivateKey = this.zbRsaPrivateKey;
        enDeSecret.zbAesKey = this.zbAesKey;
    }

    /**
     * 获取公钥
     * @return
     */
    public static String rsaPublicKey() {
        return enDeSecret.zbRsaPublicKey;
    }
    /**
     * 获取私钥
     * @return
     */
    public static String rsaPrivateKey() {
        return enDeSecret.zbRsaPrivateKey;
    }

    /**
     * 获取AES密钥
     * @return
     */
    public static String aesKey() {
        return enDeSecret.zbAesKey;
    }
}
